home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
program
/
ogrid100.zip
/
GLPARSER.INT
< prev
next >
Wrap
Text File
|
1994-12-29
|
3KB
|
96 lines
{*****************************************************************************
OOGrid Library(TM) v1.0 for Borland/Turbo Pascal (Real Mode/TV)
Copyright (C) 1994 by Arturo J. Monge
Portions Copyright (C) 1989,1990 Borland International, Inc.
Borland's parser unit:
This is Borland's TCPARSER.PAS unit with some minor
modifications necessary for adapting TParserObject for
use by the TSpreadSheet object.
Copyright (C) 1989,1990 Borland International, Inc.
Last Modification : December 29th, 1994
*****************************************************************************}
{$O+,F+,N+,E+,X+}
unit GLParser;
{****************************************************************************}
interface
{****************************************************************************}
uses Objects, GLCell, GLSupprt;
const
ParserStackSize = 10;
MaxFuncNameLen = 5;
TotalErrors = 7;
ExpLimit = 11356;
SqrLimit = 1E2466;
MaxExpLen = 4;
ErrParserStack = 1;
ErrBadRange = 2;
ErrExpression = 3;
ErrOperator = 4;
ErrOpenParen = 5;
ErrCell = 6;
ErrOpCloseParen = 7;
type
ErrorRange = 0..TotalErrors;
TokenTypes = (Plus, Minus, Times, Divide, Expo, Colon, OParen, CParen,
Num, CellT, Func, EOL, Bad, ERR);
TokenRec = record
State : Byte;
case Byte of
0 : (Value : Extended);
1 : (CP : CellPos);
2 : (FuncName : String[MaxFuncNameLen]);
end;
PParserObject = ^TParserObject;
TParserObject = object(TObject)
Inp : PString;
ParserHash : PCellHashTable;
PMaxCols : Word;
PMaxRows : Word;
Position : Word;
CurrToken : TokenRec;
StackTop : 0..ParserStackSize;
TokenError : ErrorRange;
ParseError : Boolean;
CType : CellTypes;
ParseValue : Extended;
Stack : array[1..ParserStackSize] of TokenRec;
TokenType : TokenTypes;
TokenLen : Word;
MathError, IsFormula : Boolean;
constructor Init(InitHash : PCellHashTable; InitInp : PString;
InitPMaxCols, InitPMaxRows : Word);
function IsFunc(S : String) : Boolean;
procedure Push(Token : TokenRec);
procedure Pop(var Token : TokenRec);
function GotoState(Production : Word) : Word;
procedure Shift(State : Word);
procedure Reduce(Reduction : Word);
function NextToken : TokenTypes;
procedure Parse;
function CellValue(P : CellPos) : Extended;
end;
var
StandardParser : PParserObject;
{****************************************************************************}
implementation
{****************************************************************************}
...
end. {...TSParser unit }